<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JsUnit Assertion Tests</title>
<link rel="stylesheet" type="text/css" href="jsunit/css/jsUnitStyle.css">
<script language="JavaScript" type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../content/lib/imkbizle_jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../content/sourcesite.js"></script>
<script language="JavaScript" type="text/javascript" src="../content/site_adaptors/isteyatirim.js"></script>
<script language="JavaScript" type="text/javascript">

var responseText = {};

function setUpPage() {
	imkbizle = { 
		locale: {
			getString: function(key) {
				var h = {
					"stock.Buy": "Buy",
					"stock.Sell": "Sell"
				};
				return h[key];
			}
		}
	};
	var failureHandler = function() {
		alert("oops! ajax problem!");
	}
	var successHandler = function(data, key) {
		responseText[key] = data; 
	};
	isteyatirim.url = "data/isteyatirim.THYAO.html";
	new imkbizle_jquery.ajax({
		url: isteyatirim.url,
		success: function(data) {successHandler(data, "THYAO");},
		error: failureHandler
	});
	isteyatirim.url = "data/isteyatirim.DOVIZ.html";
	new imkbizle_jquery.ajax({
		url: isteyatirim.url,
		success: function(data) {successHandler(data, "DOVIZ");},
		error: failureHandler
	});
	setTimeout('setUpPageStatus = "complete"', 2);
}

function testSiteName() {
	assertEquals("wrong site name!", "ISTEYATIRIM", isteyatirim.sitename);
}

function testSiteUrl() {
	assertEquals("wrong site url!", "data/isteyatirim.DOVIZ.html", isteyatirim.url);
}

function testCreateParams() {
	var param = isteyatirim.createParams("THYAO");
	assertEquals("malfunction on createParams method!", "THYAO", param.EnstrumanKodu);
}

function testGetName() {
	assertEquals("wrong stock name!", "THYAO", isteyatirim.getName(responseText["THYAO"]));
}

function testGetLatest() {
	assertEquals("wrong latest value!", 5.4, isteyatirim.getLatest(responseText["THYAO"]));
}

function testGetOpen() {
	assertEquals("wrong open value!", 5.45, isteyatirim.getOpen(responseText["THYAO"]));
}

function testGetChange() {
	assertEquals("wrong change value!", "%0.93", isteyatirim.getChange(responseText["THYAO"]));
}

function testGetVol() {
	assertEquals("wrong volume!", 501.107, isteyatirim.getVol(responseText["THYAO"]));
}

function testGetBuy() {
	assertEquals("wrong buy value!", "N/A", isteyatirim.getBuy(responseText["THYAO"]));
}

function testGetSell() {
	assertEquals("wrong sell value!", "N/A", isteyatirim.getSell(responseText["THYAO"]));
}

function testGetUSDTRY() {
	var usdtry = isteyatirim.getExtra("USDTRY", responseText["DOVIZ"]);
	assertEquals("wrong usdtry value!", "1,7767", usdtry.value);
	assertEquals("wrong usdtry tooltip!", "Buy: 1,7767 | Sell: 1,7853", usdtry.tooltip);
}

function testGetEURTRY() {
	var eurtry = isteyatirim.getExtra("EURTRY", responseText["DOVIZ"]);
	assertEquals("wrong usdtry value!", "2,2625", eurtry.value);
	assertEquals("wrong usdtry tooltip!", "Buy: 2,2625 | Sell: 2,2734", eurtry.tooltip);
}

</script>
</head>

<body>
<h1>Isyatirim Adaptor Tests</h1>

<p>This page contains tests for the isteyatirim adaptor for imkbizle.</p>
</body>
</html>
